<?php
// +--------------------------------------------------------------------------
// | ZAIYOUDAO [ 载攸道 先顺得常 ] <http://www.zaiyoudao.com>
// +--------------------------------------------------------------------------
// | Copyright © 2009-2016 载攸道 版权所有 <TEL:17090888854>
// +--------------------------------------------------------------------------
// | Project: YiPHP [ 我会的仅仅是偷懒！ ] <http://www.yiphp.com>
// +--------------------------------------------------------------------------
// | Author: 牛很多戒很多不戒 <n@isdce.com> <http://juexue.wang>
// +--------------------------------------------------------------------------

/**
 * Mall
 */
namespace Pay\Controller;
use Common\Controller\AdminController;

/**
 * 商品管理
 */
class OrderController extends AdminController{
	
	 public function Create(){
		 
		common_public()->assign_page('创建订单');
		
		$this->display(); 
	 }
	/**
	 * 文章管理
	 */
    public function Manage(){

		common_public()->assign_page('订单管理');
		
		$m_pay_order = M('pay_order');
		
		
		//判断是否搜索用户名
		$name = I('param.name');
		if($name){
			
			$map['name'] = array('like',"%$name%");

		}
		$this->assign('name',$name);
		

		//获得上级信息
		$type = I('param.type')?I('param.type'):0;
		
		
		//获得菜单信息
		if($type!=0){
			
			$map['type'] = $type;
		}
		
		$order_id = I('param.order_id')?I('param.order_id'):0;
		
		
		//获得菜单信息
		if($order_id!=0){
			
			$map['order_id'] = $order_id;
		}
		
		
		
		$status = I('param.status')?I('param.status'):0;
		
		
		//获得菜单信息
		if($status!=0){
			
			$map['status'] = $status;
		}else{
			$map['status'] = array('in','1,2,3');
		
		}
		
		//上传开始结束时间
		$down_money = I('param.down_money');
		$top_money = I('param.top_money');
		if($down_money != null and $top_money != null){
			
			$map['money']  = array(array('egt',$down_money),array('elt',$top_money),'and'); 
			
			$this->assign('down_money',$down_money);
			$this->assign('top_money',$top_money);
		}
		
		//开始结束时间
		$begin_time = strtotime(I('param.begin_time'));
		$end_time = strtotime(I('param.end_time'));
		if($begin_time != null and $end_time != null){
			
			$map['time']  = array(array('egt',$begin_time),array('elt',$end_time),'and'); 
			
		}else{
			
			$begin_time=time()-2592000;
			$end_time=time()+86400;
		}
		
		
		$this->assign('begin_time',$begin_time);
		$this->assign('end_time',$end_time);
		
		
	
		
		$list = $m_pay_order->where($map)->order('status asc,time desc')->page($_GET['p'].',20')->select();
	
		$count      = $m_pay_order->where($map)->count();// 查询满足要求的总记录数
		$Page       = new \Think\Page($count,20);// 实例化分页类 传入总记录数和每页显示的记录数
		$show       = $Page->show();// 分页显示输出
		$this->assign('pages',$show);
		
		//赋值
		$this->assign('list',$list);
		
		$money = $m_pay_order->where($map)->sum('money');
		$order = $m_pay_order->where($map)->count();
	
		$this->assign('money',$money);
		$this->assign('order',$order);
		
		
		$this->display();
	}
	
	
}